﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Regions;
using VpPrism.Common;
using VpPrism.Modules.ModuleTwo.ViewModels;

namespace VpPrism.Modules.ModuleTwo.Controllers
{
  /// <summary>
  /// Controller du ModuleTwo
  /// </summary>
  public class ModuleTwoMainController: IModuleTwoMainController
  {
    #region Fields
    private readonly IUnityContainer container;
    private readonly IRegionManager regionManager;
    private readonly IModuleTwoMainVM ModuleTwoMainVM;
    #endregion

    #region Constructor
    /// <summary>
    /// Constructeur. Les paramètres sont pré-remplis par le UnityContainer.
    /// </summary>
    /// <param name="container"></param>
    /// <param name="regionManager"></param>
    /// <param name="ModuleTwoMainVM"></param>
    public ModuleTwoMainController(IUnityContainer container, IRegionManager regionManager, IModuleTwoMainVM ModuleTwoMainVM)
    {
      this.container = container;
      this.regionManager = regionManager;
      this.ModuleTwoMainVM = ModuleTwoMainVM;
    }
    #endregion

    #region IModuleTwoMainController Members

    /// <summary>
    /// Lance le Controller: Injecte la vue dans la région
    /// </summary>
    public void Run()
    {
      this.regionManager.RegisterViewWithRegion(RegionNames.RegionTwo, 
                                        () => this.ModuleTwoMainVM.MainView);
    }

    #endregion
  }
}
